<?php

namespace app\api\model;

use think\Model;
use think\facade\Db;

class Scores extends Model
{
    static $tableName = 'scores';

    //接受参数 入库参数
    public static function param($request)
    {
        $data['user_id'] = $request->post('user_id') ?? null;
        $data['chinese'] = $request->post('chinese') ?? null;
        $data['english'] = $request->post('english') ?? null;
        $data['mathematics'] = $request->post('mathematics') ?? null;
        $data['score'] = $request->post('score') ?? null;
        return $data;
    }

    //添加成绩
    public static function saveScoreData($data)
    {
        $data['create_time'] = date('Y-m-d h:i:s');
        $data['update_time'] = date('Y-m-d h:i:s');
        $res = Db::name(Scores::$tableName)->insert($data);
        if (!$res){
            return false;
        }
        return true;
    }
}